﻿using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;

namespace JoshuaOneEight
{
	public partial class AboutForm : Form
	{
		#region Constructors

		/// <summary>
		/// Default Constructor
		/// </summary>
		public AboutForm()
		{
			InitializeComponent();

			mLblVersion.Text = string.Format( mLblVersion.Text,
				Assembly.GetExecutingAssembly().GetName().Version );

			mLblCopyright.Text = string.Format( mLblCopyright.Text, DateTime.Today.Year );
		}

		#endregion Constructors

		#region Private Members

		/// <summary>
		/// Handle the link clicked event of the CodePlex label.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void _HandleLblCodePlexLinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
		{
			_LaunchUrl( "http://joshua18.codeplex.com" );
		}

		/// <summary>
		/// Handle the link clicked event of the Navigators label.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void _HandleLblNavigatorsLinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
		{
			_LaunchUrl( "http://www.navigators.org/us/resources/illustrations/items/Topical%20Memory%20System" );
		}

		/// <summary>
		/// Handle the link clicked event of the NIV label.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void _HandleLblNIVLinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
		{
			_LaunchUrl( "http://www.biblegateway.com/versions/New-International-Version-NIV-Bible/" );
		}

		/// <summary>
		/// Launch a url in the browser.
		/// </summary>
		/// <param name="url"></param>
		private void _LaunchUrl( string url )
		{
			Process.Start( url );
		}

		#endregion Private Members

		#region Protected Members

		/// <summary>
		/// Handle the OnKeyDown event of the form.
		/// </summary>
		/// <param name="e"></param>
		protected override void OnKeyDown( KeyEventArgs e )
		{
			if( e.KeyCode == Keys.Escape )
			{
				Close();
				e.Handled = true;
			}

			base.OnKeyDown( e );
		}

		#endregion Protected Members

	}
}
